package com.wb.spring.boot.autoconfigure.client;

import lombok.Builder;
import org.springframework.cloud.context.named.NamedContextFactory;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author sw
 * @create 2023-03-03 11:09
 */
@Builder
public class WbClientSpecification implements NamedContextFactory.Specification {

    private String name;

    private Class<?>[] configuration;

    WbClientSpecification() {
    }

    WbClientSpecification(String name, Class<?>[] configuration) {
        this.name = name;
        this.configuration = configuration;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public Class<?>[] getConfiguration() {
        return this.configuration;
    }

    public void setConfiguration(Class<?>[] configuration) {
        this.configuration = configuration;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        WbClientSpecification that = (WbClientSpecification) o;
        return Objects.equals(this.name, that.name)
                && Arrays.equals(this.configuration, that.configuration);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.name, this.configuration);
    }

    @Override
    public String toString() {
        return new StringBuilder("WbClientSpecification{").append("name='")
                .append(this.name).append("', ").append("configuration=")
                .append(Arrays.toString(this.configuration)).append("}").toString();
    }

}

